package com.example.flower_shop.dto.address;

import com.example.flower_shop.entity.Address;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class AddressVO {
    private Long id;
    private String receiverName;
    private String receiverPhone;
    private String province;
    private String city;
    private String district;
    private String detailAddress;
    private Boolean isDefault;
    private String fullAddress; // 完整地址

    public AddressVO(AddressDTO dto) {
        this.id = dto.getId();
        this.receiverName = dto.getReceiverName();
        this.receiverPhone = dto.getReceiverPhone();
        this.province = dto.getProvince();
        this.city = dto.getCity();
        this.district = dto.getDistrict();
        this.detailAddress = dto.getDetailAddress();
        this.isDefault = dto.getIsDefault();
        this.fullAddress = String.format("%s %s %s %s",
                this.province,
                this.city,
                this.district,
                this.detailAddress);
    }

    public AddressVO(Address address) {
        this.id = address.getId();
        this.receiverName = address.getReceiverName();
        this.receiverPhone = address.getReceiverPhone();
        this.province = address.getProvince();
        this.city = address.getCity();
        this.district = address.getDistrict();
        this.detailAddress = address.getDetailAddress();
        this.isDefault = address.getIsDefault();
        this.fullAddress = String.format("%s %s %s %s",
                this.province,
                this.city,
                this.district,
                this.detailAddress);
    }
}